using System;

namespace Comteck.Winforms {
  /// <summary>
  /// DateOnly与DateTime转换
  /// </summary>
  public static class DateTimeOnlyExtensions {
    /// <summary>
    /// datetime -> dateonly
    /// </summary>
    /// <param name="dateTime"></param>
    /// <returns></returns>
    public static DateOnly ToDateOnly(this DateTime dateTime) {
      return DateOnly.FromDateTime(dateTime);
    }

    /// <summary>
    /// dateonly -> datetime
    /// </summary>
    /// <param name="dateOnly"></param>
    /// <returns></returns>
    public static DateTime ToDateTime(this DateOnly dateOnly) {
      return dateOnly.ToDateTime(TimeOnly.MinValue, DateTimeKind.Local);
    }

  }
}
